/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
    AppRegistry,
    StyleSheet,
    Text,
    View,
    Navigator,
    TouchableOpacity,
    AlertIOS
} from 'react-native';
import SecondView from './SecondView'
export default class FirstView extends Component {
    constructor(props){
        super(props)
        this.state={
            userName:null
        }
    }
    render() {
        return (
            <View style={styles.container}>
                <View style={styles.navStyle}>
                    <Text>{this.props.haha +'名字是'+this.state.userName}</Text>
                </View>
                <TouchableOpacity
                onPress={() => this.viewClick()}>
                <Text>{this.props.haha}</Text>
                </TouchableOpacity>
            </View>
        );
    }
    viewClick(){
        this.props.nav.push({

            component:SecondView,
            params:{
                title:"第一个视图",
                haha:"哈哈",
                hehe:"呵呵",
                heihei:"嘿嘿",
                getUserName:function (user) {
                    this.setState({userName:user})
                }.bind(this)
            }
        })
       // AlertIOS.alert(this.props.title);
    }
}
const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#F5FCFF',
    },
    welcome: {
        fontSize: 20,
        textAlign: 'center',
        margin: 10,
    },
    instructions: {
        textAlign: 'center',
        color: '#333333',
        marginBottom: 5,
    },
    navStyle:{

        position:'absolute',
        top:0,
        width:375,
        height:64,
        backgroundColor:'#dddddd',
        flexDirection:'row',
        justifyContent:'center',
        alignItems:'center',
        borderBottomWidth:0.5,
        borderBottomColor:'rgba(1,1,1,1)',
        paddingTop:20
    },
});